package com.da.finance;

import java.math.BigDecimal;
import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OrderBy;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import org.hibernate.annotations.Index;

import com.da.landlord.DaRoom;
import com.googlecode.cswish.annotation.cm;
import com.ra.landlord.Fee;
import com.ra.landlord.LandlordOwner;
import com.ra.landlord.LandlordOwnerUser;
import com.ra.landlord.LandlordUser;
import com.ra.landlord.Room;

@Entity
@Table(name="da_dafinancestatement")
//财务流水
public class DaFinanceStatement implements LandlordOwner{

	public static final int  TRADE_TYPE_CRASH = 1; 			//现金
	public static final int  TRADE_TYPE_WEIXIN = 0;			//微信支付
	public static final int  TRADE_TYPE_BANK_TRANSFER = 2;	//银行卡转行
	public static final int  TRADE_TYPE_ALIPAY = 3;			//支付宝
	public static final Integer STATUS_VALID = 1;			//未删除
	public static final Integer STATUS_INVALID = 0;			//已删除
	
	private Integer id;
	
	@cm("da房间")
	private DaRoom room;
	
	private Integer daRoomId;
	
	@cm("ra房间")
	private Room raRoom;
	
	private Integer raRoomId;
	
	@cm("财务类别")
	private DaFinanceCategory financeCategory;
	
	@cm("交易金额")
	private BigDecimal tradeMoney;
	
	@cm("交易时间")
	private Date tradeDate;
	
	@cm("交易方式：0现金支付，1微信支付，2银行转账，3支付宝支付")
	private Integer tradeType;
	
	@cm("备注")
	private String remark;
	
	@cm("所属房东")
	private LandlordOwnerUser landlordUser;
	
	@cm("录入人")
	private LandlordUser createUser;
	
	@cm("录入时间")
	private Date createDate;
	
	@cm("vc，集中式那边产生的费用，跟踪费用项")
	private Fee fee;

	@cm("0已删除 1未删除")
	private Integer status;
	@Id
	@GeneratedValue
	@OrderBy("id DESC")
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@Transient
	public DaRoom getRoom() {
		return room;
	}

	public void setRoom(DaRoom room) {
		this.room = room;
	}

	@ManyToOne(cascade={CascadeType.REFRESH})
	public DaFinanceCategory getFinanceCategory() {
		return financeCategory;
	}

	public void setFinanceCategory(DaFinanceCategory financeCategory) {
		this.financeCategory = financeCategory;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Index(name="idx_daFinanceStatement_tradeDate")
	public Date getTradeDate() {
		return tradeDate;
	}

	public void setTradeDate(Date tradeDate) {
		this.tradeDate = tradeDate;
	}

	public Integer getTradeType() {
		return tradeType;
	}

	public void setTradeType(Integer tradeType) {
		this.tradeType = tradeType;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	@Temporal(TemporalType.TIMESTAMP)
	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	@Override
	@ManyToOne(fetch=FetchType.LAZY)
	@Index(name = "idx_daFinanceStatement_landlordUser")
	public LandlordOwnerUser getLandlordUser() {
		return landlordUser;
	}

	@Override
	public void setLandlordUser(LandlordOwnerUser landlordUser) {
		this.landlordUser=landlordUser;
	}

	public BigDecimal getTradeMoney() {
		return tradeMoney;
	}

	public void setTradeMoney(BigDecimal tradeMoney) {
		this.tradeMoney = tradeMoney;
	}

	@ManyToOne(cascade={CascadeType.REFRESH}, fetch=FetchType.LAZY)
	public LandlordUser getCreateUser() {	
		return createUser;
	}

	public void setCreateUser(LandlordUser createUser) {
		this.createUser = createUser;
	}

	@Transient
	public Room getRaRoom() {
		return raRoom;
	}

	public void setRaRoom(Room raRoom) {
		this.raRoom = raRoom;
	}
	
	@ManyToOne(fetch=FetchType.LAZY)
	@Index(name="idx_da_dafinancestatement_fee_id")
	//@NotFound(action = NotFoundAction.IGNORE)
	public Fee getFee() {
		return fee;
	}

	public void setFee(Fee fee) {
		this.fee = fee;
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}
	
	@Column(name = "room_id")
	public Integer getDaRoomId() {
		return daRoomId;
	}

	public void setDaRoomId(Integer daRoomId) {
		this.daRoomId = daRoomId;
	}

	@Column(name = "raRoom_room_id")
	public Integer getRaRoomId() {
		return raRoomId;
	}

	public void setRaRoomId(Integer raRoomId) {
		this.raRoomId = raRoomId;
	}

}
